#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
#include<assert.h>
#if 0
size_t my_strlen(const char* str)
{
	if (*str == '\0')
		return 0;
	else
		return 1 + my_strlen(str + 1);
}
int main()
{
	char arr[] = "abcdef";
	printf("%zd\n", my_strlen(arr));
	return 0;
}
#endif

#if 0
int main()
{
	char arr1[] = "abcdef";
	char arr2[20] = { 0 };
	strcpy(arr2, arr1);
	printf("%s\n", arr2);
	return 0;
}
#endif
#if 0
char* my_strcpy(char* s1, const char* s2)
{
	assert(s1 != NULL);
	assert(s2 != NULL);
	char* ret = s1;
	//while (*s2 != '\0')
	//{
		//*s1 = *s2;
		//s1++;
		//s2++;
		//*s1++ = *s2++;
	   //}
	*s1 = *s2;//
	while (*s1++ = *s2++)
	{
		;
	}
	return ret;
}
int main()
{
	char arr1[] = "hello world";
	char arr2[20] = "xxxxxxxxxxxxxxxx";
	char*ret=my_strcpy(arr2, arr1);
	printf("%s\n", arr2);
	printf("%s\n", ret);
	return 0;
}
#endif
#if 0
int main()
{
	char arr1[20] = "hello ";
	char arr2[] = "world";
	strcat(arr1, arr2);
	printf("%s\n", arr1);
	return 0;
}
#endif
char* my_strcat(char* s1, const char* s2)
{
	assert(s1 && s2);
	char* ret = s1;
	while (*s1 != '\0')
		s1++;
	while (*s1++ = *s2++);
	return ret;
}
int main()
{
	char arr1[20] = "hello ";
	char arr2[] = "world";
	my_strcat(arr1, arr2);
	printf("%s\n", arr1);
	return 0;
}